package com.eastfair.venueservice.controller;

import com.eastfair.venueservice.entity.SettlementRecord;
import com.eastfair.venueservice.dto.SettlementRecordSaveDTO;
import com.eastfair.venueservice.dto.SettlementRecordUpdateDTO;
import com.eastfair.venueservice.dto.SettlementRecordPageQuery;
import com.eastfair.venueservice.service.SettlementRecordService;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.eastfair.boot.controller.SuperController;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eastfair.echo.core.EchoService;
import com.eastfair.core.base.R;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import com.eastfair.annotation.annotation.security.PreAuth;

import com.eastfair.boot.request.PageParams;
import com.eastfair.core.context.ContextUtil;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * 结算记录
 * </p>
 *
 * @author dqq
 * @date 2022-12-28
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/settlement")
@Api(value = "SettlementRecord", tags = "结算记录")
@PreAuth(replace = "venueservice:settlement:")
public class SettlementRecordController extends SuperController<SettlementRecordService, Long, SettlementRecord, SettlementRecordPageQuery, SettlementRecordSaveDTO, SettlementRecordUpdateDTO> {

    @Autowired
    private EchoService echoService;

    @Override
    public void handlerResult(IPage<SettlementRecord> page) {
        // 想让返回值实现自动回显，请将此行代码打开
        // echoService.action(page);
    }
    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<SettlementRecord> settlementList = list.stream().map((map) -> {
            SettlementRecord settlement = SettlementRecord.builder().build();
            //TODO 请在这里完成转换
            return settlement;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(settlementList));
    }



    /**
     * 处理参数
     *
     * @param params 分页参数
     */
    @Override
    public void handlerQueryParams(PageParams<SettlementRecordPageQuery> params) {
        SettlementRecordPageQuery pageQuery = params.getModel();
    }

}
